#include "wolf.hpp"
#include "nature.hpp"

Event *Wolf::run()
{
    this->m_hunger += 10;

    if (m_hunger >= 100)
    {
        Event *e = new Event(NET_DIE, Nature::get_instance()->get_round());
        e->set_id(this->m_id);
        e->set_old_pos(this->m_position);
        e->set_new_pos(this->m_position);

        this->die();

        return e;
    }

    std::cout << "Wolf " << m_id << " run." << std::endl;

    // TODO 狼的生存规则

    if (this->m_hunger > 10)
    {
        Event *e = this->foraging();
        if (nullptr == e)
        {
            std::cout << "foraging failed..." << std::endl;
            return this->stroll();
        }
        else
        {
            return e;
        }
    }
    else
    {
        return this->stroll();
    }
}
